﻿@model Sheng.WeixinConstruction.Management.Shell.Models.PortalStyle_CustomViewModel

@{
    ViewBag.MainMenu = "Portal";
    ViewBag.LeftMenu = "PortalStyle";

    ViewBag.Title = "微主页设置";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">

    var _validator;

    $(document).ready(function () {
        if (_online == false)
            return;

        _validator = $("#form").validate({
            onfocusout: false,
            onkeyup: false,
            showErrors: showValidationErrors,
            rules: {
                "txtCustomTemplate": "required"
            },
            messages: {
                "txtCustomTemplate": "请输入自定义 Html；"
            }
        });
    });
    @if (ViewBag.Domain.Type != Sheng.WeixinConstruction.Infrastructure.EnumDomainType.Free)
    {
        <text>
    function save() {
        if (_validator.form() == false) {
            return;
        }

        var loadLayerIndex = layer.load(0, {
            shade: [0.2, '#fff']
        });

        var args = new Object();
        args.PortalCustomTemplate = $("#txtPortalCustomTemplate").val();

        var url = "/Api/Portal/SavePortalStyleSettings_Custom";

        $.ajax({
            url: url,
            type: "POST",
            dataType: "json",
            data: JSON.stringify(args),
            success: function (data, status, jqXHR) {
                layer.close(loadLayerIndex);
                if (data.Success) {
                    layerAlert("保存成功，您的设置将在几分钟之内生效。");
                } else {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest) {
                layer.close(loadLayerIndex);
                alert("Error: " + xmlHttpRequest.status);
            }
        });
    }
    </text>
    }

</script>

<div id="divContentTips">
    在此完全自定义您的微主页HTML代码，您可以在代码中使用我们预留的接口。
</div>

<div style="margin-top:10px;">
    您可以在“公众号菜单”中，添加微主页菜单，也可通过微信官方后台将此 URL 添加到菜单中访问微主页。
</div>
<div class="divBorder_lightgray" style="margin-top:10px;padding:10px;font-size:13px;">
    http://@(ViewBag.DomainContext.AppId).wxc.shengxunwei.com/Home/Portal/@(ViewBag.Domain.Id)
</div>

<div style=" margin-top:20px;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td class="td_ContentTab" style="width:200px;"><a href="/Portal/PortalStyle_Template" class="a_black_16">基于模版</a></td>
            <td class="td_ContentTab_active" style="width:200px;">自定义</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="4" bgcolor="#EEEEEE" height="2"></td>
        </tr>
    </table>
</div>
<div>
    <form id="form">
        <div style="margin-top:15px;line-height:24px;">
            将您的 Html 代码粘贴到此处，注意：<br />
            1）只需 Body 标签以内的内容即可，无需包含 Body 标签；<br />
            2）页面文本尺寸已预定义为：fontSize = 100 * (clientWidth / 320) + 'px'，请使用 rem 作为文本尺寸单位；<br />
            3）页面中已为您引入了以下 js 文件：jQuery 1.10.2，layer mobile 1.6 以及预置了一些基本功能函数的 portalCommon.js<br />
            4）页面中预定义了一些对象、函数及标签，请参考下表中的详细说明；<br />
            请 <a href="http://wxcfile1.shengxunwei.com/OtherFiles/customTemplateDemo.zip">点击此处</a> 下载 DEMO，并在此基础上开发您的微主页。
        </div>
        <div style="margin-top:15px;">
            <textarea rows="10" class="input_16" id="txtPortalCustomTemplate" name="txtPortalCustomTemplate">@Model.CustomTemplate</textarea>
        </div>
    </form>
</div>

<div style=" margin-top:15px;">

    @if (ViewBag.Domain.Type != Sheng.WeixinConstruction.Infrastructure.EnumDomainType.Free)
    {
        <input name="btnSave" type="button" class="btn_blue" id="btnSave" value="保存" onclick="save()" />
    }
    else
    {
        <input name="btnSave" type="button" class="btn_blue" id="btnSave" value="保存" disabled />
        @Helpers.VipIcon()
    }

</div>
<div style="margin-top:15px;">可在您的 Html 代码中使用以下标签，展现时将被替换为对应内容：</div>
<div style="margin-top:15px;">
    <table width="100%" border=border cellpadding="5" cellspacing=0 bordercolor="#E0E0E0" rules=rows>
        <tr bordercolor="#E0E0E0">
            <td width="5" valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
            <td width="280" height="26" valign="middle" bgcolor="#EEEEEE">标签</td>
            <td valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#HeadImageUrl_64}}</td>
            <td valign="top">当前用户头像 64px</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#NickName}}</td>
            <td valign="top">当前用户昵称</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#Point}}</td>
            <td valign="top">当前用户积分</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#PointCommodityUrl}}</td>
            <td valign="top">积分商城Url</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#PointCommodityOrderListUrl}}</td>
            <td valign="top">积分订单Url</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#PointAccountUrl}}</td>
            <td valign="top">积分账户信息Url</td>
        </tr>

        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#CashAccount}}</td>
            <td valign="top">当前用户现金账户余额</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#PayOrderListUrl}}</td>
            <td valign="top">现金账户订单Url</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#CashAccountTrackUrl}}</td>
            <td valign="top">现金账户信息Url</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#CashAccountDepositUrl}}</td>
            <td valign="top">现金账户充值Url</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#MemberCenterUrl}}</td>
            <td valign="top">会员中心Url</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#PersonalInfoUrl}}</td>
            <td valign="top">个人信息Url</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">{{#CampaignListUrl}}</td>
            <td valign="top">活动中心Url</td>
        </tr>
    </table>
</div>
<div style="margin-top:15px;">预定义对象：</div>
<div style="margin-top:15px;">
    <table width="100%" border=border cellpadding="5" cellspacing=0 bordercolor="#E0E0E0" rules=rows>
        <tr bordercolor="#E0E0E0">
            <td width="5" valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
            <td width="280" height="26" valign="middle" bgcolor="#EEEEEE">_member （当前会员信息）</td>
            <td width="80" height="26" valign="middle" bgcolor="#EEEEEE"></td>
            <td valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">_member.point</td>
            <td valign="top">int</td>
            <td valign="top">当前积分。</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">_member.signedIn</td>
            <td valign="top">bool</td>
            <td valign="top">是否已签到。</td>
        </tr>
    </table>
</div>
<div style="margin-top:15px;">预定义函数，可在您的 Html 代码中直接调用：</div>
<div style="margin-top:15px;">
    <table width="100%" border=border cellpadding="5" cellspacing=0 bordercolor="#E0E0E0" rules=rows>
        <tr bordercolor="#E0E0E0">
            <td width="5" valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
            <td width="280" height="26" valign="middle" bgcolor="#EEEEEE">函数</td>
            <td valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">signIn()</td>
            <td valign="top">每日签到。</td>
        </tr>
    </table>
</div>
<div style="margin-top:15px;">预留函数调用，需要您在代码中自行实现：</div>
<div style="margin-top:15px;">
    <table width="100%" border=border cellpadding="5" cellspacing=0 bordercolor="#E0E0E0" rules=rows>
        <tr bordercolor="#E0E0E0">
            <td width="5" valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
            <td width="280" height="26" valign="middle" bgcolor="#EEEEEE">函数</td>
            <td valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">documentReady()</td>
            <td valign="top">页面加载完成后调用，请在此实现您的页面初始化逻辑，而不要使用 $(document).ready ，以确保系统自身的页面初始化完毕后再执行您的初始化代码。</td>
        </tr>
        <tr bordercolor="#E0E0E0">
            <td valign="middle">&nbsp;</td>
            <td height="26" valign="top">signInCallback(result)</td>
            <td valign="top">
                每日签到回调。如果不定义此函数，将在签到成功或失败时显示一个弹框提示。<br>
                <br>
                <table width="100%" border=border cellpadding="5" cellspacing=0 bordercolor="#E0E0E0" rules=rows>
                    <tr bordercolor="#E0E0E0">
                        <td width="5" valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
                        <td width="200" height="26" valign="middle" bgcolor="#EEEEEE">result （签到结果）</td>
                        <td width="80" height="26" valign="middle" bgcolor="#EEEEEE"></td>
                        <td valign="middle" bgcolor="#EEEEEE">&nbsp;</td>
                    </tr>
                    <tr bordercolor="#E0E0E0">
                        <td valign="middle">&nbsp;</td>
                        <td height="26" valign="top">result.reason</td>
                        <td valign="top">int</td>
                        <td valign="top">
                            签到结果。<br>
                            0: 成功 1: 今日已经签到过了
                        </td>
                    </tr>
                    <tr bordercolor="#E0E0E0">
                        <td valign="middle">&nbsp;</td>
                        <td height="26" valign="top">result.signInPoint</td>
                        <td valign="top">int</td>
                        <td valign="top">本次获得积分。</td>
                    </tr>
                </table><br />
            </td>
        </tr>
    </table>
</div>